package mysql

import "gorm.io/gorm"

type Good struct {
	gorm.Model
	GoodName  string  `gorm:"type:varchar(15);not null;comment:商品名称"`
	GoodNum   string  `gorm:"type:varchar(15);not null;comment:商品编号"`
	GoodPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品价格"`
	GoodStock int64   `gorm:"type:int;not null;comment:商品库存"`
	GoodLike  int64   `gorm:"type:int;not null;comment:商品收藏"`
	GoodAdopt int     `gorm:"type:tinyint;default:1;comment:状态:1.待审核,2.审核通过"`
}

func (g *Good) Create() error {
	return DB.Create(&g).Error
}

func (g *Good) GoodInfo(GoodId int) error {
	return DB.Where("id = ?", GoodId).First(&g).Error
}
